<?php

namespace App\Http\Controllers;

use App\Utils\QiniuFileManager;
use Response;

class QiniuController extends Controller {
	
	private $_qiniuFileManager;

	public function __construct(QiniuFileManager $qiniuFileManager){
		$this->_qiniuFileManager = $qiniuFileManager;
	}

	public function getUpToken() {
		return Response::json(["uptoken" => $this->_qiniuFileManager->getUploadToken()]);
	}

	public function getFileUrl() {
		$fileKey = request("fileKey");

		$fileUrl = $this->_qiniuFileManager->getFileUrl($fileKey, "private");

		return Response::json(["url" => $fileUrl]);
	}

	
}